<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>ip管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#inputForm").validate({
	            rules:{
                	ip:{
	                	checkContactsIp:true,
	                	remote: "${ctx}/rsa/ips/isIpsByIp?oldIp=" + encodeURIComponent('${ips.ip}')
	                },
	                phone:{ 
	                	checkPhone:true,
	                }
	            },
	            messages: {
					ip: {remote: "ip地址已存在"},
				},
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		    $.validator.addMethod("checkContactsIp",function(value,element,params){ 
	            var ip = /^(?:(?:2[0-4][0-9]\.)|(?:25[0-5]\.)|(?:1[0-9][0-9]\.)|(?:[1-9][0-9]\.)|(?:[0-9]\.)){3}(?:(?:2[0-5][0-5])|(?:25[0-5])|(?:1[0-9][0-9])|(?:[1-9][0-9])|(?:[0-9]))$/;  
	            return this.optional(element)||(ip.test(value));  
	        },"请输入正确的ipv4格式地址！");
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
	<li>
		<shiro:hasPermission name="rsa:ips:list">
			<a href="${ctx}/rsa/ips/">ip列表</a>
		</shiro:hasPermission>
	</li>
	<li class="active">
		<shiro:hasPermission name="rsa:ips:update">
			<a href="${ctx}/rsa/ips/openUpdate?id=${ips.id}">ip修改</a>
		</shiro:hasPermission>
	</li>
</ul><br/>
	<form:form id="inputForm" modelAttribute="ips" action="${ctx}/rsa/ips/update" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">ip：</label>
			<div class="controls">
				<form:input path="ip" htmlEscape="false" maxlength="30" class="input-xlarge required"/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="rsa:ips:update">
				<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
			</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>